package io.renren.modules.pullin.dao;

import io.renren.modules.jxgk.entity.CollegeInfoEntity;
import io.renren.modules.jxgk.entity.ElectiveCourseEntity;
import io.renren.modules.jxgk.entity.TeacherInfoEntity;
import io.renren.modules.pullin.entity.ClassCourse;
import io.renren.modules.jxgkphone.entity.StudentInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Repository
@Mapper
public interface PullOutDao {
    //课程信息
    @Insert("INSERT INTO class_course (course_teacher_name,course_school_id,course_name,course_teacher_id,class_course_id,class_id,course_academic_term,course_academic_year,course_which_week,course_which_day,course_which_index,course_classroom_position,class_name,course_time,student_department_name)" +
            "VALUES(#{course_teacher_name},#{course_school_id},#{course_name},#{course_teacher_id},#{class_course_id},#{class_id},#{course_academic_term},#{course_academic_year},#{course_which_week},#{course_which_day},#{course_which_index},#{course_classroom_position},#{class_name},#{course_time},#{student_department_name})")
    void insertClassCourse(ClassCourse cc);
    @Select("Select * FROM class_course WHERE class_name=#{class_name} AND course_school_id=#{course_school_id}")
    List<ClassCourse> findClassCourseByClassNameAndCourseId(@Param("class_name") String class_name,@Param("course_school_id")String course_school_id);
    @Delete("Delete FROM class_course WHERE class_name=#{class_name} AND course_school_id=#{course_school_id}")
    void DeleteClassCourseByClassNameAndCourseId(@Param("class_name") String class_name,@Param("course_school_id")String course_school_id);

    //学生信息
    @Insert("INSERT INTO student_info(student_current_grade,student_department,student_class_name,student_school_id,student_name,student_sexual,student_birthday," +
            "student_ethnicity,student_profession_name,student_schooling_year,student_study_length,student_enroll_date,student_tel_number,student_profession_code) " +
            "VALUES(#{studentCurrentGrade},#{studentDepartment},#{studentClassName},#{studentSchoolId}, #{studentName}, #{studentSexual},#{studentBirthday},#{studentEthnicity},#{studentProfessionName},#{studentSchoolingYear},#{studentStudyLength},#{studentEnrollDate},#{studentTelNumber},#{studentProfessionCode})")
    void insertStudentInfo(StudentInfo si);
    @Select("Select * FROM student_info WHERE student_school_id=#{student_school_id}")
    StudentInfo findStudentInfoByStudentId(String student_school_id);

    //教师信息
    @Insert("INSERT INTO teacher_info(" +
            "      teacher_id," +
            "      teacher_name," +
            "      teacher_sexual," +
            "      teacher_birthday," +
            "      teacher_type," +
            "      teacher_college)" +
//            "      teacher_tel_number,\n" +
//            "      teacher_email_address,\n" +
//            "      teacher_position,\n" +
//            "      teacher_education,\n" +
//            "      teacher_title,\n" +
//            "      teacher_research_direction,\n" +
//            "      teacher_priority,\n" +
//            "      teacher_class_distribution,\n" +
//            "      teacher_profession_name,\n" +
//            "      teacher_graduated_school,\n" +
//            "      teacher_qualifications,\n" +
//            "      teacher_personnel_id,\n" +
//            "      teacher_whether_external,\n" +
//            "      teacher_whether_laboratory,\n" +
//            "      teacher_whether_on_duty,\n" +
//            "      teacher_political_status,\n" +
//            "      teacher_ethnic,\n" +
//            "      teacher_degree,\n" +
//            "      teacher_whether_counselor,\n" +
//            "      teacher_pinyin_short) " +
            " VALUES(" +
            "#{teacherId}," +
            "#{teacherName}," +
            "#{teacherSexual}," +
            "#{teacherBirthday}," +
            "#{teacherType}," +
            "#{teacherCollege})"
//            "#{teacherTelNumber}," +
//            "#{teacherEmailAddress}," +
//            "#{teacherPosition},\n" +
//            "#{teacherEducation}," +
//            "#{teacherTitle}," +
//            "#{teacherResearchDirection}," +
//            "#{teacherPriority}," +
//            "#{teacherClassDistribution},\n" +
//            "#{teacherProfessionName}," +
//            "#{teacherGraduatedSchool}," +
//            "#{teacherQualifications}," +
//            "#{teacherPersonnelId},\n" +
//            "#{teacherWhetherExternal}," +
//            "#{teacherWhetherLaboratory}," +
//            "#{teacherWhetherOnDuty}," +
//            "#{teacherPoliticalStatus},\n" +
//            "#{teacherEthnic}," +
//            "#{teacherDegree}," +
//            "#{teacherWhetherCounselor}," +
//            "#{teacherPinyinShort})"
    )
    void insertTeacher(TeacherInfoEntity t);
    @Select("Select * from teacher_info WHERE teacher_id=#{teacher_id}")
    TeacherInfoEntity findTeacherInfobyTeacherId(String teacher_id);
    @Delete("Delete from teacher_info WHERE teacher_id=#{teacher_id}")
    void deleteTeacherInfoByTeacherId(String teacher_id);
    @Delete("Delete from student_info WHERE student_school_id=#{studentSchoolId}")
    void deleteStudentInfoByStudentId(String studentSchoolId);
    //选修课信息
    @Insert("Insert INTO elective_course( " +
            "     course_name,\n" +
            "     student_id,\n" +
            "     teacher_id,\n" +
            "     student_name,\n" +
            "     teacher_name,\n" +
            "     course_time,\n" +
            "     is_evaluation,\n" +
            "     course_which_index,\n" +
            "     course_classroom,\n" +
            "     course_id) " +
            "VALUES( " +
            "     #{courseName},\n" +
            "     #{studentId},\n" +
            "     #{teacherId},\n" +
            "     #{studentName},\n" +
            "     #{teacherName},\n" +
            "     #{courseTime},\n" +
            "     #{isEvaluation},\n" +
            "     #{courseWhichIndex},\n" +
            "     #{courseClassroom},\n" +
            "     #{courseId}) ")
    void insertElectiveCourse(ElectiveCourseEntity t);
    @Select("Select * FROM elective_course WHERE student_id=#{studentId} AND course_time=#{courseTime}" +
            "")
    List<ElectiveCourseEntity> findElectiveCourseByStudentIdAndCourseTime(@Param("studentId") String studentId,@Param("courseTime")String courseTime);
    @Delete("Delete FROM elective_course WHERE student_id=#{studentId} AND course_time=#{courseTime}")
    void DeleteElectiveCourseByStudentIdAndCourseTime(@Param("studentId") String studentId,@Param("courseTime")String courseTime);
    @Insert("INSERT INTO class_info ( class_id, class_name, profession_name, college_name, grade ) SELECT\n" +
            "student_class_name,\n" +
            "student_class_name,\n" +
            "student_profession_name,\n" +
            "student_department,\n" +
            "student_current_grade \n" +
            "FROM\n" +
            "\tstudent_info WHERE student_class_name is not null\n" +
            "GROUP BY\n" +
            "\tstudent_class_name")
    void InsertClassInfo();
    @Delete("Delete from class_info")
    void DeleteClassInfo();
    @Select("select * from college_info where college_code=#{collegeCode}")
    CollegeInfoEntity findCollegeInfobyCollegeCode(String collegeCode);
    @Insert("Insert into college_info(college_name,college_code) values(#{collegeName},#{collegeCode})")
    void insertCollege(CollegeInfoEntity collegeInfoEntity);
    @Delete("delete from college_info where college_code=#{collegeCode}")
    void deleteCollegeInfoByCollegeCode(String collegeCode);
    //副表
    @Select("select * from college_info_copy where college_code=#{collegeCode}")
    CollegeInfoEntity findCollegeInfoCopybyCollegeCode(String collegeCode);
    @Insert("Insert into college_info_copy(college_name,college_code) values(#{collegeName},#{collegeCode})")
    void insertCollegeCopy(CollegeInfoEntity collegeInfoEntity);
    @Delete("delete from college_info_copy where college_code=#{collegeCode}")
    void deleteCollegeInfoCopyByCollegeCode(String collegeCode);
}
